package com.rd.student.jike.class2.lihongming.Slolution3;

/**
 * @Auther:Heinrich
 * @Date:2023/7/19-07-19-15:19
 * @Description:com.rd.student.jike.class2.lihongming.Solution719
 * @version:1.0
 */
public class Question2 {
    public static void main(String[] args) throws InterruptedException{
        int sum = 0;
        for (int i = 1; i <= 10; i++) {
            sum += sumReturn(10*(i-1)+1, 10*i);
        }
        System.out.println(sum);
    }
    public static int sumReturn (int min,int max)throws InterruptedException{
        AddSum addSum = new AddSum(min,max);
        Thread thread = new Thread(addSum);
        thread.start();
        thread.join();
        return addSum.sum;
    }
}
class AddSum implements Runnable{
    int min;
    int max;

    int sum = 0;

    public AddSum(int min, int max) {
        this.min = min;
        this.max = max;
    }

    @Override
    public void run() {
        synchronized (this) {
            for (int i = this.min; i <= this.max; i++) {
                this.sum += i;
            }
        }
    }
}